from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView, TokenVerifyView
from django.urls import path, re_path
from users.views import CreateUserView, RegisterView, MobileAPIView, SmsAPIView, SmsLoginView, UserInfoView
from rest_framework import routers

router = routers.DefaultRouter()
router.register('userinfo',UserInfoView)

urlpatterns = [
    path('jwt/access/',TokenObtainPairView.as_view()),
    path('jwt/refresh/',TokenRefreshView.as_view()),
    path('jwt/verify/',TokenVerifyView.as_view()),
    path('createuser/',CreateUserView.as_view()),
    path('register/',RegisterView.as_view()),
    path('login/sms/', SmsLoginView.as_view()),

    # re_path用于匹配基于正则表达式的URL路由的函数
    # (?P<mobile>1[3-9]\d{9}) 是一个命名捕获组，匹配符合正则的字符串，并将其命名为mobile
    # 这是一个动态路由，即路径中包含变量，如手机号码
    # 手机号的唯一校验
    re_path(r'^mobile/(?P<mobile>1[3-9]\d{9})/$', MobileAPIView.as_view()),
    re_path(r'^sendsms/(?P<mobile>1[3-9]\d{9})/$',SmsAPIView.as_view()),
]+router.urls